package ua.maxicash.util.criteria.handlers;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Junction;
import org.hibernate.criterion.Restrictions;
import ua.maxicash.util.Filter;
import ua.maxicash.util.criteria.RestrictionsWrapper;

import java.util.List;

public class WageCriteriaHandler extends CriteriaHandler{
    private Filter filter;

    public WageCriteriaHandler() {
    }

    public WageCriteriaHandler(List<String> aliases) {
        super(aliases);
    }

    @Override
    public void setUp(Filter filter) {
        this.filter = filter;
    }

    @Override
    public DetachedCriteria handle(DetachedCriteria criteria, Junction junction) {
        
    	junction.add(RestrictionsWrapper.getCriterion(filter.getOp(), "wage", Double.parseDouble(filter.getData())));
    	return criteria;
    }
}
